<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- 可选的Bootstrap主题文件（一般不用引入） -->
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="js/jquery-1.9.1.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="js/bootstrap.min.js"></script>
<!-- 引入主题样式 -->
<link href="themes/bootstrap/easyui.css" rel="stylesheet"></link>
<!-- 引入图标样式 -->
<link href="themes/icon.css" rel="stylesheet"></link>
<!-- 引入jquer -->
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<!-- 引入easyui.js -->
<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
<!-- 引入本地语言 -->
<script type="text/javascript" src="js/easyui-lang-zh_CN.js"></script>
<title>个人信息</title>
</head>
<script type="text/javascript">
	$(function() {
		
		//默认对话框是关闭的
		$('#updAdmin').dialog('close');
		//显示修改框
		$('#updateAdmin').click(function() {
			$('#updAdmin').dialog('open');
			//年龄的修改限制
			$("#adminage").blur( function () 
					{ 
				        var aage = $('#adminage').val();
				        if(!/^(?:[1-9][0-9]?|1[01][0-9]|120)$/.test(aage)){
				        	alert('年龄必须是整数,且范围在1-120之间');
						return false;
						}
				        
					});
			//登录名限制
			$("#adminname").blur( function () 
					{ 
				        var aname = $('#adminname').val();
				        if(aname.length==0){
							alert("登录名不能为空");
							return false;					
						}
				        if(aname.length>10){
							alert("登录名不能大于10位");
							return false;					
						}
					});
			//密码限制
			$("#adminpsw").blur( function () 
					{ 
				        var apsw = $('#adminpsw').val();
				        if(apsw.length==0){
							alert("密码不能为空");
							return false;					
						}
				        if(apsw.length>20){
							alert("密码不能大于20位");
							return false;					
						}
					});

        });
		$("#updateAdm").click(function() {
			var aid = $("#adminid").val();
		    var aname = $("#adminname").val();
			var apsw = $("#adminpsw").val();
			var asex = $("input:radio:checked").val();
			var aage = $("#adminage").val();
			$.ajax({
					//提交的方式
					type : 'post',
					//请求的地址
					url : 'updateAdminInFo',
					//回复的类型dataType
					dataType : 'json',
					//请求提交的数据
					data : {
							'aid' : aid,
							'aname' : aname,
							'apsw' : apsw,
							'asex' : asex,
							'aage' : aage
								},
					//成功后的业务逻辑
					success : function(data) {

						if (data.state == '1') {

							$.messager.confirm('提示','更新成功,你修改了登录名或密码，请重新登录！',function(r) {
									if (r) {
										//跳出iframe框架
										top.location.href = "${pageContext.request.contextPath}/";
										   };
									});
						}else if(data.state == '3'){
							$.messager.alert('警告', '更新失败,你未做修改，请做修改或退出！');
						}
						else if(data.state == '2'){
							$.messager.confirm('提示','更新成功!',function(r) {
								if (r) {								
										 $.each(data,function(i,item){
											    if(item.sex!=null&&item.age) {
											   	 var sex = item.sex;
								                 var age = item.age;							               
								                 document.getElementById('xb').innerHTML=sex;
								                 $("#nl").attr("value",age);
								                 $("#adminage").attr("value",age);
								                 $('#updAdmin').dialog('close');
								                  
											    }  
											        											 						
										 });    
									   };
								});
						}
						
						
					 }
							

					})
				});

})
</script>
<body style="background-image: url(images/44.jpg);width:100%;height:100%;">
	<div class="container-fluid" style="background-image: url(images/44.jpg);width:100%;height:100%;">
		<div class="row">
			<div class="col-md-3" style=""></div>
			<div class="col-md-6" style="">
				<form role="form" id="admininfo">
					<fieldset disabled>
						<div class="form-group" style="display: none;" id="aid">
							<label for="disabledTextInput">登陆id</label> <input type="text"
								id="disabledTextInput" class="form-control"
								value="${currentadmin.aid}">
						</div>
						<div class="form-group" id="aname">
							<label for="disabledTextInput">登陆名</label> <input type="text"
								id="disabledTextInput" class="form-control"
								value="${currentadmin.aname}">
						</div>
						<div class="form-group" id="apsw">
							<label for="disabledTextInput">密码</label> <input type="text"
								id="disabledTextInput" class="form-control"
								value="${currentadmin.apsw}">
						</div>
						<div class="form-group" id="asex">
							<label for="disabledTextInput">性别</label> 
							<div id="xb">
							   <c:choose>
									    <c:when test="${currentadmin.asex == 1}">
									       男
									    </c:when>
									    <c:when test="${currentadmin.asex == 0}">
									       女
									    </c:when>
									</c:choose>
							</div>
								
						</div>
						<div class="form-group" id="aage">
							<label for="disabledTextInput">年龄</label> <input type="text"
								id="nl" class="form-control"
								value="${currentadmin.aage}">
						</div>
						<div class="form-group" id="adep">
							<label for="disabledTextInput">所属部门</label> <input type="text"
								id="disabledTextInput" class="form-control"
								value="${currentadmin.adep}">
						</div>
						<div class="form-group" id="asalary">
							<label for="disabledTextInput">工资</label> <input type="text"
								id="disabledTextInput" class="form-control"
								value="${currentadmin.asalary}">
						</div>
					</fieldset>
					<div>
						<button id="updateAdmin" type="button"
							class="btn btn-default btn-sm">修改</button>
					</div>
				</form>

				<!-- 修改信息的对话框 -->
				<div id="updAdmin" class="easyui-dialog" title="修改信息"
					style="width: 400px; height: 450px;" data-options="modal:true">
					<form id="updadmin" action="" method="post">
						<div style="margin-bottom: 20px; display: none;">
							<span>登陆id</span> <input id="adminid" class="easyui-textbox"
								name="aid" style="width: 100%; height: 40px"
								value="${currentadmin.aid}">
						</div>
						<div style="margin-bottom: 20px">
							<span>登陆名</span> <input id="adminname" class="easyui-validatebox"
								name="aname" style="width: 100%; height: 40px" data-options="required: true,missingMessage:'登录名必填'"
								value="${currentadmin.aname}">
						</div>
						<div style="margin-bottom: 20px">
							<span>密码</span> <input id="adminpsw" class="easyui-validatebox"
								name="apsw" style="width: 100%; height: 40px" data-options="required: true,missingMessage:'登录密码必填'"
								value="${currentadmin.apsw}">

						</div>
						<div id=" " style="margin-bottom: 20px">
							<span>年龄</span> 
							     <div>  
								<label class="radio-inline"> <input id="nan" type="radio"
								name="asex"  value="1" checked >
								男
							</label> <label class="radio-inline"> <input id="nv" type="radio"
								name="asex"  value="0">
								女
							</label>
							     </div>
								
						</div>
						<div style="margin-bottom: 20px">
							<span>年龄</span> <input id="adminage" class="easyui-validatebox"
								name="aage" style="width: 100%; height: 40px" data-options="required: true,missingMessage:'年龄必须是整数,且范围在0-150之间'"
								value="${currentadmin.aage}">

						</div>
						<div>
							<input id="updateAdm" type="button"
								class="btn btn-default btn-sm" value="提交" />
						</div>
					</form>

				</div>

			</div>
			<div class="col-md-3" style=""></div>
		</div>
	</div>
</body>
</html>